//
//  HeaderView2.m
//  Marketing
//
//  Created by Hanen 3G 01 on 16/5/19.
//  Copyright © 2016年 Hanen 3G 01. All rights reserved.
//

#import "HeaderView2.h"
#define CellH 55.0f

@implementation HeaderView2
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self layOutViewsWithFrame:frame];
    }
    return self;
}

- (void)layOutViewsWithFrame:(CGRect)frame
{
    UILabel *title = [ViewTool getLabelWith:CGRectMake(20, 0, 80.0f, CellH) WithTitle:@"全部" WithFontSize:16.0f WithTitleColor:blackFontColor WithTextAlignment:NSTextAlignmentLeft];
    [self addSubview:title];
    
    
    
    _coverBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, frame.size.width - 110, frame.size.height)];
    _coverBtn.backgroundColor = [UIColor clearColor];
        _coverBtn.selected = NO;
    [self addSubview:_coverBtn];
    [_coverBtn addTarget:self action:@selector(selectExpand:) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *lien = [ViewTool getLineViewWith:CGRectMake(0, frame.size.height - 1, frame.size.width, 1) withBackgroudColor:grayLineColor];
    [self addSubview:lien];
}

//点击 是否伸展的
- (void)selectExpand:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(clickAllWithIndexPath:withSendeSelectedWith:)]) {
        [self.delegate clickAllWithIndexPath:self.section withSendeSelectedWith:sender.selected == NO? YES : NO];
    }
    sender.selected = !sender.selected;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
